<!-- script代码，如果需要引用js文件，请使用与HTML中相同的方式。 -->
<script type="text/javascript">
    /*
     *  TODO
     *  请在此处编写javascript代码
     */
	 
	
	//转岗生效日期
	var zgsxrqfield = "field9922";
	//考核开始日期
	var khksrqfield = "field9783";
	//考核期限
	var khqxfield = "field9782";
	//考核到期日
	var khdqrfield = "field9784";
	
	
	
	function addDate(date, days) {
		if(days == undefined || days == '') {
			days = 1;
		}
		var date = new Date(date);
		date.setDate(date.getDate() + days);
		var month = date.getMonth() + 1;
		var day = date.getDate();
		var mm = "'" + month + "'";
		var dd = "'" + day + "'";
		
		//单位数前面加0
		if(mm.length == 3) {
			month = "0" + month;
		}
		if(dd.length == 3) {
			day = "0" + day;
		}

		var time = date.getFullYear() + "-" + month + "-" + day
		return time;
    }
	
	jQuery().ready(function(){
		
		
		jQuery("#"+zgsxrqfield).bindPropertyChange(function(){
			var zgsxrq_val = jQuery("#"+zgsxrqfield).val();
			
			
			if(jQuery("#"+khksrqfield).attr("type")=='hidden'){ 
				jQuery("#"+khksrqfield+"span").html(zgsxrq_val);
			}
			
			
		})
		
		jQuery("#"+khqxfield).bindPropertyChange(function(){
			var khqxfield_val = jQuery("#"+khqxfield).val();
			var zgsxrq_val = jQuery("#"+zgsxrqfield).val();
			
			if(khqxfield_val == 0){
				var addTime = addDate(zgsxrq_val, 30);
				if(jQuery("#"+khdqrfield).attr("type")=='hidden'){ 
					jQuery("#"+khdqrfield+"span").html(addTime);
				}else{
					jQuery("#"+khdqrfield).val(addTime);
				}
			}else if(khqxfield_val == 1){
				var addTime = addDate(zgsxrq_val, 60);
				if(jQuery("#"+khdqrfield).attr("type")=='hidden'){ 
					jQuery("#"+khdqrfield+"span").html(addTime);
				}else{
					jQuery("#"+khdqrfield).val(addTime);
				}
			}else if(khqxfield_val == 2){
				var addTime = addDate(zgsxrq_val, 90);
				if(jQuery("#"+khdqrfield).attr("type")=='hidden'){ 
					jQuery("#"+khdqrfield+"span").html(addTime);
				}else{
					jQuery("#"+khdqrfield).val(addTime);
				}
			}
			
		})
		
		
		
		
	})
	
	

	
	
</script>
